home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / demos / samples / StdBBox.tcl.z / StdBBox.tcl
Encoding:
Text File  |  1999-01-26  |  2.0 KB  |  62 lines

  1. # Tix Demostration Program
  2. #
  3. # This sample program is structured in such a way so that it can be
  4. # executed from the Tix demo program "widget": it must have a
  5. # procedure called "RunSample". It should also have the "if" statment
  6. # at the end of this file so that it can be run as a standalone
  7. # program using tixwish.
  8.  
  9. # This file demonstrates the use of the tixStdButtonBox widget, which is a
  10. # group of "Standard" buttons for Motif-like dialog boxes.
  11. #
  12. proc RunSample {w} {
  13.  
  14.     # Create the label on the top of the dialog box
  15.     #
  16.     label $w.top -padx 20 -pady 10 -border 1 -relief raised -text \
  17.     "This dialog box is\n a demostration of the\n tixStdButtonBox widget" \
  18.     -justify center -anchor c
  19.  
  20.     # Create the button box. We also do some manipulation of the
  21.     # button widgets inside: we disable the help button and change
  22.     # the label string of the "apply" button to "Filter"
  23.     #
  24.     # Note that the -text, -underline, -command and -width options are all
  25.     # standard options of the button widgets.
  26.     #
  27.     tixStdButtonBox $w.box
  28.     $w.box subwidget ok     config \
  29.     -command "puts {OK pressed}; destroy $w"
  30.     $w.box subwidget apply  config -text "Filter" -underline 0 \
  31.     -command "puts {Filter pressed}"
  32.     $w.box subwidget cancel config \
  33.     -command "puts {Cancel pressed}; destroy $w"
  34.     $w.box subwidget help config -state disabled
  35.  
  36.     pack $w.box -side bottom -fill x
  37.     pack $w.top -side top -fill both -expand yes -anchor c
  38.  
  39.  
  40.     # "after 0" is used so that the key bindings won't interfere with
  41.     # tkTraverseMenu
  42.     #
  43.     bind [winfo toplevel $w] <Alt-o> \
  44.     "after 0 tkButtonInvoke [$w.box subwidget ok]"
  45.     bind [winfo toplevel $w] <Alt-f> \
  46.     "after 0 tkButtonInvoke [$w.box subwidget apply]"
  47.     bind [winfo toplevel $w] <Alt-c> \
  48.     "after 0 tkButtonInvoke [$w.box subwidget cancel]"
  49.     bind [winfo toplevel $w] <Escape> \
  50.     "after 0 tkButtonInvoke [$w.box subwidget cancel]"
  51.  
  52.     focus [$w.box subwidget apply] 
  53. }
  54.  
  55. if {![info exists tix_demo_running]} {
  56.     wm withdraw .
  57.     set w .demo
  58.     toplevel $w
  59.     RunSample $w
  60.     bind $w <Destroy> exit
  61. }
  62.